package cn.xtcode.domain.activity.service.trial.factory;

import cn.xtcode.domain.activity.model.entity.MarketProductEntity;
import cn.xtcode.domain.activity.model.entity.TrialBalanceEntity;
import cn.xtcode.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.xtcode.domain.activity.model.valobj.SkuVO;
import cn.xtcode.domain.activity.service.trial.node.RootNode;
import cn.xtcode.types.design.framework.tree.StrategyHandler;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @Author xt-code
 * @Description:
 * @Create 2025/5/6 12:00
 */
@Service
public class DefaultActivityStrategyFactory {

    private final RootNode rootNode;

    public DefaultActivityStrategyFactory(RootNode rootNode) {
        this.rootNode = rootNode;
    }

    public StrategyHandler<MarketProductEntity, DynamicContext, TrialBalanceEntity> strategyHandler(){
        return rootNode;
    }

    //动态上下文。串联功能节点数据
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class DynamicContext {

        // 拼团活动营销配置值对象
        private GroupBuyActivityDiscountVO groupBuyActivityDiscountVO;
        // 商品信息
        private SkuVO skuVO;

        // 折扣价格
        private BigDecimal deductionPrice;

        //支付金额
        private BigDecimal payPrice;

        //活动可见性
        private boolean visible;

        //活动可否参与性
        private boolean enable;
    }
}
